#!/bin/bash

# ----------------------------------------------------------------------
# Filename:   75634-setenforce.sh
# Version:    1.0
# Date:       2013/12/17
# Author:     yuanhui.shi
# Email:      yuanhui.shi@cs2c.com.cn
# Summary:    03系统安全功能-01SELinux-03SELinux重要命令-01SELinux运行状态-03setenforce运行状态切换
# Notes:      getenforce
# Copyright:  China Standard Software Co., Ltd.
# History：     
#             Version 1.0, 2013/12/17
#             -   The first one
# ----------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ../../lib/XmlParse.sh
source ./lib/Selib.sh

function CleanData ()
{
  setenforce ${SELINUX_STATUS}
  EchoInfo "75634-setenforce.sh执行完毕"
}

trap "CleanData" EXIT

CheckSElinuxStatus

SELINUX_STATUS=`getenforce`

EchoInfo "开始检验setenforce命令执行结果是否正确"

setenforce 1
[ "`getenforce`" == "Enforcing" ]
EchoResult "命令setenforce 1 执行正确"

setenforce Enforcing
[ "`getenforce`" == "Enforcing" ]
EchoResult "命令setenforce Enforcing 执行正确"

setenforce enforcing
[ "`getenforce`" == "Enforcing" ]
EchoResult "命令setenforce enforcing 执行正确"

setenforce 0
[ "`getenforce`" == "Permissive" ]
EchoResult "命令setenforce 0 执行正确"

setenforce Permissive
[ "`getenforce`" == "Permissive" ]
EchoResult "命令setenforce Permissive 执行正确"

setenforce permissive
[ "`getenforce`" == "Permissive" ]
EchoResult "命令setenforce permissive 执行正确"

